﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.gradeinfo
{
    public partial class ModifyZZ : lcs.Web.Admin.BasePage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int gdid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(gdid);
                }
            }
        }

        private void ShowInfo(int gdid)
        {
            lcs.BLL.gradeinfo bll = new lcs.BLL.gradeinfo();
            lcs.Model.gradeinfo model = bll.GetModel(gdid);
            this.lblgdid.Text = model.gdid.ToString();
            this.txtyls.Text = model.yls.ToString();
            this.txtyle.Text = model.yle.ToString();
            this.txtscs.Text = model.scs.ToString();
            this.txtsce.Text = model.sce.ToString();
            this.txtscwte1.Text = model.scwte1.ToString();
            this.txtzzs.Text = model.zzs.ToString();
            this.txtzze.Text = model.zze.ToString();
            //this.txtylmark.Text=model.ylmark.ToString();
            //this.txtscmark.Text=model.scmark.ToString();
            //this.txtzzmark.Text=model.zzmark.ToString();		

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            int gdid = int.Parse(this.lblgdid.Text);
            //int monthsupplyid=int.Parse(this.txtmonthsupplyid.Text);
            decimal yls = decimal.Parse(this.txtyls.Text);
            decimal yle = decimal.Parse(this.txtyle.Text);
            decimal scs = decimal.Parse(this.txtscs.Text);
            decimal sce = decimal.Parse(this.txtsce.Text);
            decimal scwte1 = decimal.Parse(this.txtscwte1.Text);
            decimal zzs = decimal.Parse(this.txtzzs.Text);
            decimal zze = decimal.Parse(this.txtzze.Text);
            lcs.Model.gradeinfo model = new lcs.Model.gradeinfo();
            model.gdid = gdid;
           
            model.yls = yls;
            model.yle = yle;
            model.scs = scs;
            model.sce = sce;
            model.scwte1 = scwte1;
            model.zzs = zzs;
            model.zze = zze;
            decimal jg = 0;
            jg = yle / yls;
            if (jg <= 0.03M)
            {
                jg = 10 - jg * 200;
            }
            else
                jg = 0;

            model.ylmark = jg;
            //IF(K7/J7+M7/L7<=0.05,5-100*K7/J7-100*M7/L7,0)
            jg = sce / scs + scwte1 / scs;
            if (jg <= 0.05M)
            {
                jg = 5 - jg * 100;
            }
            else
                jg = 0;

            model.scmark = jg;
            //IF(O7/N7>=0.95,5-(1-O7/N7)*100,0)
            jg = zze / zzs;
            if (jg >= 0.95M)
            {
                jg = 5 - (1 - jg) * 100;
            }
            else
                jg = 0;

            model.zzmark = jg;
            model.pfdatetime = DateTime.Now;
            lcs.BLL.gradeinfo bll = new lcs.BLL.gradeinfo();
            bll.UpdateZZ(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "mylist.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("mylist.aspx");
        }
    }
}
